<!DOCTYPE html>
<html lang = "pt-BR">
    <head>
        <?php
        session_start();
        include_once'bloco/head.php';
        include_once '../control/conexao.php';
        include_once '../control/valida_sessao.php';

        function __autoload($classe) {
            include_once"../model/{$classe}.class.php";
        }
        ?>
        <link href="bootstrap/css/morris.css" rel="stylesheet">
    </head>
    <body>      
        <div id="wrapper">
            <?php
            include_once'bloco/navbar.php';
            include_once '../control/valida_perfil.php';
            ?>
            <div id="page-wrapper">
                <?php include_once 'bloco/banner.php'; ?>                  
                <div class="row">
                    <div class=" panel panel-success">
                        <div class="panel-heading">
                            <p class="panel-title"><i class = "glyphicon glyphicon-th-large"></i> Lista de Perfis</p>
                        </div>
                        <div class="panel-body">
                            <div class="col-lg-12">                                
                                <div class="row">
                                    <div class="col-md-8 col-md-offset-2">                                        
                                        <?php
                                        $perfilDAO = new perfilDAO();
                                        $arPerfil = $perfilDAO->listar();
                                        ?>
                                        <div>
                                            <a href="cadastrar_perfil.php"><input type="button" class="btn btn-success" value="Novo Perfil"></a>
                                        </div><br/>
                                        <table class="table table-responsive table-striped table-condensed table-bordered">
                                            <tr>                                                
                                                <td align="center"><strong>Perfil</strong></td>
                                                <td align="center"><strong>Alterar</strong></td>
                                                <td align="center"><strong>Excluir</strong></td>
                                                <td align="center"><strong>gerenciar</strong></td>
                                            </tr>
                                            <?php for ($c = 0; count($arPerfil) > $c; $c++) { ?>
                                                <tr>                                                
                                                    <td align="center"><?php echo utf8_encode($arPerfil[$c]->perfil_nome) ?></td>
                                                    <td align="center"><a href="editar_perfil.php?id=<?php echo utf8_encode($arPerfil[$c]->id_perfil) ?>"><i class="glyphicon glyphicon-edit"></i></a></td>
                                                    <td align="center"><a onclick="return confirma_perfil()" href="../control/excluir_perfil.php?id=<?php echo utf8_encode($arPerfil[$c]->id_perfil) ?>"><i class="glyphicon glyphicon-remove"></i></a></td>
                                                    <td align="center"><a href="gerenciar_perfil.php?id=<?php echo utf8_encode($arPerfil[$c]->id_perfil) ?>"><i class="glyphicon glyphicon-wrench"></i></a></td>
                                                </tr>
                                            <?php } ?>
                                        </table>
                                    </div>
                                </div>                                
                            </div>
                        </div>
                    </div>
                </div>                
            </div>
        </div>
        <?php
        include_once'bloco/scripts.php';
        ?>
        <script type="text/javascript">
            function confirma_perfil() {
                var opcao = confirm("Excluir este Perfil?");
                if (opcao == false) {
                    return false
                    exit();
                }
            }
        </script>
    </body>
</html>